package route

/**
 * @title 总路由
 *
 * @author wz
 *
 * @date 2025/10/23 14:13
 *
 * @version 1.0
 */

import (
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"

	"test-gin/internal/controller"
)

func SetupRouter(db *gorm.DB) *gin.Engine {
	r := gin.New()
	r.Use(gin.Recovery())

	// 用户路由组
	userRoutes := r.Group("/api/v1/users")
	{
		userController := controller.NewUserController(db)
		userRoutes.POST("", userController.CreateUser)
		userRoutes.GET("/:id", userController.GetUser)
	}

	return r
}
